var RiskView = function(elements)
{
	this.elements 		    = elements;
	this.imgDiv			    = elements.imgDiv;
	this.coveringDiv	    = elements.coveringDiv;
	this.map			    = elements.map;
	this.areas              = elements.areas;  				//map_info
	this.playerStatusDiv    = elements.playerStatusDiv;  	//user_info
	this.messageBox    		= elements.messageBox;  	//user_info
	this.userInfo			= elements.userInfo;

	this.init();

	/*
	this.messageBox.fn.gameStatus =  function(title, message)
	{
		this.obj.append(String.format("<div id='gameStatusDiv'>status: {0}</div>", title));
		this.obj.append(String.format("<div id='gameStatusMessageDiv'>{0}</div>", message));
	};*/
};

RiskView.prototype = {
	init: function()
	{
		console.debug("init view");
		this.imgDiv.addClass("mapper noborder");
		this.coveringDiv.css("display", "none");

	},
	updatePlayerStatus: function (playerModels)
	{
		var div = this.playerStatusDiv;

		/*
		var html = "";
			"		<table>" +
			"			<tr>" +
			"			<td class='playerState'>status</td>" +
			"			<td colspan=5 class='playerState'>" + playerModels[0].status + "</td>" + 
			"			</tr>" +
			"		</table>";
			*/
		var html = "";
		for (var i = 0; i < playerModels.length; i++)
		{
			var player = playerModels[i];
			var contentId = "cardDiv";
/*
			var callback = function(data){
				console.debug(data);
				alert('finished');
			};
*/
			
			html +=
			"	<div id='player"+i+"Wrapper'" + (player.turn == 1? 'class=yellow' : '' ) + ">" + 
			"		<div id='player"+i+"'statusDiv' class='playerStatusName'>" + 
			" 			<div id='graph"+ i + "' class='ball'></div>" + player.username + (player.isYou ? ' (you)' : '') + 
			"			<span class='playerState'>"+ player.playerState +"</span>" + 
			"		</div>" + 
			"		<table>" +
			"			<tr>" +
			"			<td id='playerStatusArmies'>troops</td><td>" + player.troops_left + "/" + player.troops + "</td>" +
			"			<td>lands</td><td>" + player.numberOfLands + "</td>" +
			"			<td><a href='javascript:riskController.sendCardMessage({getCards:1,user:" + player.session_key + "})'>card</a>" + player.card_number +"</td>" +
			"			</tr>" +
			//"			<tr>" +
			//"			<td class='playerState'>status</td>" +
			//"			<td colspan=5 class='playerState'>" + player.status + "</td>" + 
			//"			</tr>" + 
			/*
			"			<tr>" +
			"			<td class='playerState'>playerState</td>" +
			"			<td colspan=5 class='playerState'>" + player.playerState + "</td>" + 
			"			</tr>" + 
			"			<tr>" +
			"			<td colspan=6></td>" + 
			"			</tr>" + 
			"			<tr>" +
			"			<td colspan=6 class='ownedLands'>" + player.ownedLands.join() + "</td>" + 
			"			</tr>" + 
			*/
			"		</table>" +
			"	</div><!-- end of player" +i+"Wrapper -->";

		}


		html += "<div id='cardDiv'>cardDiv</div>";

		$(div).html(html);


		for (var i = 0; i <playerModels.length; i++)
		{

			showArmy('graph' + i, i, i);

		}

	}


};


